#!/usr/bin/env python

import os 
wxpy = 0

def sudo():	
	userid = os.getuid()
	if wxpy == 1:
		if not userid == 0:
			print "You need Be root to install cpufreq"
		else:
			runlevel = os.popen('runlevel').read()[-2]
			cpfile = open('filecp.sh','a')
			cpfile.write('cp ./lib/S97cpufreq  /etc/rc%s.d/' %(runlevel))
			cpfile.close() 
			action()
	
def action():
	os.popen('./lib/S97cpufreq')
	os.popen('./filecp.sh')
	print "Done !!!\n\t run cpufreq now."	
	

if  __name__ == "__main__":
	try :
		import wx
	except ImportError:
		print "You need install wxpython first \n\t please See ReadMe"
	else:
		wxpy = 1
		sudo()
